import Vue from "vue"
import index from "./index.vue"

let Loading = Vue.extend(index)
let instance

export default {
    open(options) {
        if(window.showLoadingProxy){
          window.showLoadingProxy()
          return
        }
        if (!instance) {
            instance = new Loading({
                el: document.createElement("div")
            })
            document.body.appendChild(instance.$el)
        }
        
        Object.assign(instance, options)
        

        Vue.nextTick(() => {
            instance.show = true
        })
    },
    close() {
        if(window.showLoadingProxy){
          window.hideLoadingProxy()
          return
        }
        setTimeout(() => {
            instance.show = false
        }, 1)
    }
}